home *** CD-ROM | disk | FTP | other *** search
/ The Interactive History of Frankenstein / The Interactive History of Frankenstein.iso / pc / setup.mst < prev    next >
Encoding:
Text File  |  1995-02-28  |  13.8 KB  |  424 lines

  1. rem Required Includes for use with MSSETUP DLL's
  2. rem -------------------------------------------------
  3. '$INCLUDE 'setupapi.inc'
  4. '$INCLUDE 'msdetect.inc'
  5.  
  6. rem Dialog box id's
  7. rem ---------------
  8.     CONST DESTPATH      = 300          ''Gets destination path
  9.     CONST EXITQUIT      = 600          ''Exits on user request
  10.     CONST EXITSUCCESS   = 700          ''Exits when install is done
  11.     CONST ASKSETUP      = 800          ''Gets setup options
  12.     CONST REBOOTWARN    = 900           ''Warn User of impending restart
  13.     CONST REGMSG        = 950           ''Reminder to user to register Product
  14.     CONST QTWLAUNCH        = 1000           ''Tell User how to Launch QTW 2.0 Setup
  15.     CONST QTWWARN        = 1100           ''Allow user to setup QTW 2.0
  16.     CONST TOOBIG        = 6300         ''Not enough space on target disk error
  17.     CONST BADPATH       = 6400         ''Bad destination path error
  18.     CONST BADWINDOWS    = 6500         ''Wrong Windows release
  19.     CONST BADCOLORS     = 6550         ''Not in 256 colors
  20.     CONST EXITFAILURE   = 6600         ''Exits on error
  21.  
  22.  
  23. rem String id's
  24. rem -----------
  25.     CONST STR_UTILITY   = 1024         ''Utility
  26.     CONST STR_GROUP     = 1025         ''Program Manager group
  27.     CONST STR_TITLE     = 1026         ''Installer Title
  28.     CONST STR_MSG1      = 1027         ''Version error message part 1
  29.     CONST STR_MSG2      = 1028         ''Version error message part 2
  30.     CONST STR_WARNING   = 1029         ''Warning
  31.     CONST STR_SIREADME  = 1030         ''SI Read Me
  32.     CONST STR_PROGRAM   = 1031         ''SI Almanac program
  33.  
  34.  
  35. rem Miscellaneous Constants
  36. rem -----------------------
  37.     CONST NOLOGO = 1                   ''Dummy NULL bitmap (must be 1)
  38.     CONST LOGO = 2                     ''Background bitmap
  39.     CONST NOSPACE = 1                  ''No space to complete install
  40.     CONST INSTALLOK = 2                ''Install completed OK
  41.     CONST INSTALLFAILED = 3            ''Install failed for some reason
  42.     CONST UNINSTALLOK = 4              ''Uninstall completed OK
  43.  
  44.  
  45. rem Global Variables
  46. rem ----------------
  47.     GLOBAL SOURCE$                     ''Source directory
  48.     GLOBAL DEST$                       ''Default destination directory
  49.     GLOBAL MYSYSDIR$                   ''Windows/System directory
  50.     GLOBAL MYWINDIR$                   ''Windows directory
  51.     GLOBAL SETUPTYPE$                  ''Setup type (Local, Client, Server)
  52.     GLOBAL MINIMUMINST$                  ''Setup type (Local, Client, Server)
  53.     GLOBAL PARTIALINST$                ''Setup type (Local, Client, Server)
  54.     GLOBAL OPTIMUMINST$                   ''Setup type (Local, Client, Server)
  55.     GLOBAL QTWDIR$                     ''QTW directory
  56.     GLOBAL CUIDLL$                     ''User interface DLL
  57.     GLOBAL SETUPPATH$                  ''Setup destination path
  58.     GLOBAL HELPPROC$                   ''Help dialog procedure
  59.     GLOBAL EXTRACOSTS$                 ''List of extra costs to add per drive
  60.     GLOBAL APPNEEDS$                   ''Disk space costs per drive
  61.     GLOBAL SECTIONKEY$                 ''INF file section key
  62.     GLOBAL SUCCESS%                    ''Installation completion code
  63.  
  64.  
  65. rem Initialize global vriables
  66. rem --------------------------
  67.     MINIMUMINST$    = "MIN"
  68.     OPTIMUMINST$    = "OPT"
  69.     SETUPTYPE$        = MINIMUMINST$
  70.     SETUPPATH$      = "C:\FRANK"
  71.     SOURCE$         = GetSymbolValue("STF_SRCDIR")
  72.     DEST$           = SETUPPATH$
  73.     SUCCESS%        = INSTALLFAILED
  74.     EXTRACOSTS$     = "ExtraCosts"
  75.     APPNEEDS$       = "AppNeeds"
  76.     SECTIONKEY$     = "SectionKey"
  77.  
  78.     FOR i% = 1 TO 26 STEP 1
  79.         AddListItem EXTRACOSTS$, "16384"
  80.     NEXT i%
  81.  
  82.  
  83. rem Get name of localized user interface dialogs
  84. rem --------------------------------------------
  85.     CUIDLL$ = "setup.DLL"
  86.  
  87.  
  88. rem Subroutines and Functions
  89. rem -------------------------
  90.     DECLARE FUNCTION Install (Level$) AS INTEGER
  91.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  92.     DECLARE FUNCTION GetDLLVersion LIB "setup.dll" (szDLL$) AS INTEGER
  93.     DECLARE FUNCTION HideCriticalDirectory LIB "setup.dll" (szDir$) AS INTEGER
  94.     DECLARE FUNCTION Has256Colors LIB "setup.dll" (hinst%) AS INTEGER
  95.     DECLARE FUNCTION GetResourceString LIB "setup.dll" (szResource$, idString%) AS INTEGER
  96.     DECLARE FUNCTION StartCustomSetup LIB "setup.dll" (hinst%, hwnd%) AS INTEGER
  97.     DECLARE FUNCTION StopCustomSetup LIB "setup.dll" (hinst%, hwnd%) AS INTEGER
  98.     DECLARE FUNCTION SendMessage LIB "USER.EXE" (hWnd%, Message%, wParam%, lParam&) AS LONG
  99.     DECLARE FUNCTION ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER
  100.  
  101. rem Initialize custom setup logic
  102. rem -----------------------------
  103. rem SetBitmap CUIDLL$, NOLOGO
  104.     i% = GetResourceString (CUIDLL$, STR_TITLE)
  105.     SetTitle GetSymbolValue ("ResourceString")
  106.     i% = StartCustomSetup (HinstFrame(), HwndFrame ())
  107.     i% = SetBeepingMode(1)
  108.  
  109.  
  110. rem Make sure that we are running on Windows 3.1 or better
  111. rem ------------------------------------------------------
  112.     IF GetWindowsMajorVersion() < 3 THEN
  113.        sz$ = UIStartDlg(CUIDLL$, BADWINDOWS, "FInfo0DlgProc", 0, "")
  114.        UIPop 1
  115.        GOTO CLEANUP
  116.     END IF
  117.  
  118.     IF (GetWindowsMajorVersion() = 3) AND (GetWindowsMinorVersion() < 10) THEN
  119.        sz$ = UIStartDlg(CUIDLL$, BADWINDOWS, "FInfo0DlgProc", 0, "")
  120.        UIPop 1
  121.        GOTO CLEANUP
  122.     END IF
  123.  
  124.  
  125. rem Make sure that we are running on a 386 or better
  126. rem ------------------------------------------------
  127.     IF GetWinFlags() AND 2 THEN
  128.        sz$ = UIStartDlg(CUIDLL$, BADWINDOWS, "FInfo0DlgProc", 0, "")
  129.        UIPop 1
  130.        GOTO CLEANUP
  131.     END IF
  132.  
  133. rem Determine if QTW 2.0 is installed
  134. rem ---------------------------------
  135. exist%=0
  136. exist%=DoesFileExist(MYSYSDIR$+"QTNOTIFY.EXE",femExists)
  137. version$="0"
  138. IF exist% then
  139.     version$=GetVersionOfFile(MYSYSDIR$+"QTNOTIFY.EXE")
  140. END IF    
  141.  
  142. IF exist%=0 then
  143.     sz$=UIStartDlg(CUIDLL$,QTWWARN,"FRadioDlgProc",0,"")    
  144. else 
  145.     if mid$(version$,1,1) <> "2" then
  146.         sz$=UIStartDlg(CUIDLL$,QTWWARN,"FRadioDlgProc",0,"")        
  147.     end if
  148. end if
  149.  
  150. if sz$="EXIT" then
  151.     UIPop 1
  152.     sz$=UIStartDlg(CUIDLL$,QTWLAUNCH,"FRadioDlgProc",0,"")
  153.     GOTO CLEANUP
  154. else
  155.     UIPop 1
  156. END IF
  157.  
  158.  
  159. rem Find and read the .INF file
  160. rem ---------------------------
  161.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  162.  
  163.     IF szInf$ = "" THEN
  164.        szTemp$ = GetSymbolValue("STF_SRCDIR")
  165.        szInf$ = szTemp$ + "FRANK.INF"
  166.     END IF
  167.  
  168.     ReadInfFile szInf$
  169.  
  170.  
  171. rem Estimate the cost of the install
  172. rem --------------------------------
  173.     ListSym$ = APPNEEDS$
  174.     drive$ = MID$("C:\", 1, 1)
  175.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  176.     AddSectionFilesToCopyList "Frankenstein", SOURCE$, "C:\"
  177.     ClearCopyList
  178.  
  179. rem Get the setup type
  180. rem ----------------------------------------
  181. ITYPE:
  182.     rem SetSymbolValue "RadioDefault", SETUPTYPE$
  183.  
  184. ITYPEL1:
  185.     sz$ = UIStartDlg(CUIDLL$, ASKSETUP, "FRadioDlgProc", 0, "")
  186.  
  187.     rem SETUPTYPE$ = GetSymbolValue("ButtonChecked")
  188.  
  189.     IF sz$ = "CONTINUE" THEN
  190.         SETUPTYPE$=OPTIMUMINST$
  191.        UIPop 1
  192.  
  193.     ELSEIF sz$ = "CANCEL" THEN
  194.         SETUPTYPE$=MINIMALINST$
  195.         UIPop 1
  196.  
  197.     ELSE
  198.        GOSUB ASKQUIT
  199.        GOTO ITYPE
  200.  
  201.     END IF
  202.  
  203. if SETUPTYPE$=MINIMALINST$ then 
  204.     GOTO INSTALL
  205. END IF
  206.  
  207. rem Get the destination path; if it's bad, display an error
  208. rem ----------------------------------------------------------------
  209. GETPATH:
  210.     SetSymbolValue "EditTextIn", DEST$
  211.     SetSymbolValue "EditFocus", "END"
  212.  
  213. GETPATHL1:
  214.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", 0, "")
  215.  
  216.     DEST$ = GetSymbolValue("EditTextOut")
  217.  
  218.     IF sz$ = "CONTINUE" THEN
  219.        IF IsDirWritable(DEST$) = 0 THEN
  220.           GOSUB BADPATH
  221.           GOTO GETPATHL1
  222.        END IF
  223.  
  224.        UIPop 1
  225.  
  226.     ELSEIF sz$ = "REACTIVATE" THEN
  227.        GOTO GETPATHL1
  228.  
  229.     ELSE
  230.        GOSUB ASKQUIT
  231.        GOTO GETPATH
  232.  
  233.     END IF
  234.  
  235. rem Perform actual installation
  236. rem ---------------------------
  237. INSTALL:
  238.     SUCCESS% = Install(SETUPTYPE$)
  239.  
  240.     IF SUCCESS% = NOSPACE THEN
  241.        GOSUB TOOBIG
  242.        GOTO GETPATH
  243.     END IF
  244.  
  245. rem De-installation completed
  246. rem -------------------------
  247. UNINSTALLED:
  248.  
  249. rem When done, issue dialog
  250. rem -----------------------
  251. QUIT:
  252.     IF SUCCESS% = INSTALLOK THEN
  253.     rem Remind User about Registering Product
  254.     sz$ = UIStartDlg(CUIDLL$, REGMSG, "FInfo0DlgProc", 0, "")
  255.     UIPop 1
  256.  
  257.     rem Restart Windows 
  258.     'sz$ = UIStartDlg(CUIDLL$, REBOOTWARN, "FInfo0DlgProc", 0, "")
  259.     '   Check if any files were locked during install.  If the RestartList
  260.     '   is not empty, ExitExecRestart() will restart Windows, cleanup setup
  261.     '   files, and copy over locked files before Windows restarts.
  262.     i% = RestartListEmpty()
  263.     IF i% = 0 THEN
  264.     '      ExitExecRestart() only returns if applications refuse to be shutdown.
  265.     '      Win32s is installed but will not operate until Windows is restarted
  266.     '      and the Win32s VxD is loaded.
  267.     '    i% = ExitExecRestart()
  268.     ELSE
  269.     '      If the RestartList list is empty, it is necessary to restart windows
  270.     '      directly.  The MSSETUP program creates _MSRSTRT.EXE and _MSSETUP.BAT
  271.     '      in the restart directory.  This program should be exec'd to handle
  272.     '      proper MSSETUP cleanup (temp files) and restart Windows.
  273.     '    i% = ExitWindowsExec( GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT" )
  274.     ENDIF
  275.     
  276.     ELSEIF SUCCESS% = UNINSTALLOK THEN
  277.        sz$ = UIStartDlg(CUIDLL$, EXITDEINSTOK, "FInfo0DlgProc", 0, "")
  278.     ELSE
  279.        sz$ = UIStartDlg(CUIDLL$, EXITFAILURE, "FInfo0DlgProc", 0, "")
  280.     END IF
  281.     UIPop 1
  282.     
  283. rem Clean up all processing
  284. rem -----------------------
  285. CLEANUP:
  286.     i% = StopCustomSetup (HinstFrame(), HwndFrame ())
  287.     END
  288.  
  289.  
  290. rem ASKQUIT: The user requested quit; does (s)he really want to?
  291. rem ------------------------------------------------------------
  292. ASKQUIT:
  293.     sz$ = UIStartDlg(CUIDLL$, EXITQUIT, "FInfoDlgProc", 0, "")
  294.     UIPop 1
  295.     IF sz$ = "CONTINUE" THEN
  296.        RETURN
  297.     END IF
  298.     GOTO CLEANUP
  299.  
  300.  
  301. rem BADPATH: The user entered an invalid destination directory
  302. rem ----------------------------------------------------------
  303. BADPATH:
  304.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  305.     IF sz$ = "REACTIVATE" THEN
  306.        GOTO BADPATH
  307.     END IF
  308.     UIPop 1
  309.  
  310.     RETURN
  311.  
  312.  
  313. rem TOOBIG: The source files won't fit on the requested destination disk
  314. rem --------------------------------------------------------------------
  315. TOOBIG:
  316.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  317.     IF sz$ = "REACTIVATE" THEN
  318.        GOTO TOOBIG
  319.     END IF
  320.     UIPop 1
  321.  
  322.     RETURN
  323.  
  324. rem Install: Perform actual installation
  325. rem ------------------------------------
  326. FUNCTION Install (Level$) STATIC AS INTEGER
  327.  
  328.     rem Create the destination directory
  329.     rem --------------------------------
  330.         IF Level$=OPTIMUMINST$ then 
  331.             CreateDir DEST$, cmoNone
  332.         END IF
  333.  
  334.     rem Determine the Windows\System directory
  335.     rem --------------------------------------
  336.         MYSYSDIR$ = GetWindowsSysDir
  337.  
  338.     rem Build the copy list
  339.     rem -------------------
  340.         if Level$=OPTIMUMINST$ then 
  341.             AddSectionFilesToCopyList "Frankenstein", SOURCE$, DEST$
  342.         END IF
  343.  
  344.     rem Check that we have enough free space to perform the install
  345.     rem -----------------------------------------------------------
  346.         ListSym$ = APPNEEDS$
  347.         StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  348.  
  349.         drive$ = MID$(DEST$, 1, 1)
  350.         ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  351.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%))
  352.         free& = GetFreeSpaceForDrive(drive$)
  353.  
  354.         IF cost& >= free& THEN
  355.            Install = NOSPACE
  356.            EXIT FUNCTION
  357.         END IF
  358.  
  359.     rem Copy all the files from the source to the destination
  360.     rem -----------------------------------------------------
  361.         CopyFilesInCopyList
  362.  
  363.     rem Create a Program Manager group and appropriate items
  364.     rem ----------------------------------------------------
  365.         i% = GetResourceString (CUIDLL$, STR_GROUP)
  366.         GROUP$ = GetSymbolValue ("ResourceString")
  367.         CreateProgmanGroup GROUP$, "", cmoNone
  368.  
  369.         i% = GetResourceString (CUIDLL$, STR_PROGRAM)
  370.         IF Level$=OPTIMUMINST$ then
  371.             CreateProgmanItem GROUP$, GetSymbolValue ("ResourceString"), MakePath(DEST$,"FRANK.exe"), "", cmoOverwrite
  372.         else
  373.             CreateProgmanItem GROUP$, GetSymbolValue ("ResourceString"), MakePath(SOURCE$,"frank.exe"), "", cmoOverwrite
  374.         END IF
  375.         i% = GetResourceString (CUIDLL$, STR_SIREADME)
  376.         CreateProgmanItem GROUP$, GetSymbolValue ("ResourceString"), MakePath(SOURCE$,"readme.txt"), "", cmoOverwrite
  377.  
  378.         CreateProgmanItem GROUP$, "Mary Shelley's Frankenstein 1818", MakePath(SOURCE$,"1818.WRI"), "", cmoOverwrite
  379.         CreateProgmanItem GROUP$, "Mary Shelley's Frankenstein 1831", MakePath(SOURCE$,"1831.WRI"), "", cmoOverwrite
  380.  
  381.         CreateProgmanItem GROUP$, "Quicktime for Windows 2.0 Installer", MakePath(SOURCE$,"QTW20\setup.exe"), "", cmoOverwrite
  382.  
  383.     rem Save Paths when program installed to HD
  384.     rem ---------------------------------------
  385.  
  386.     rem Check for \ at end of path
  387.     REM --------------------------
  388.         if Level$=OPTIMUMINST$ then
  389.             if mid$(SOURCE$,len(SOURCE$),1) <> "\" then
  390.                 SOURCE$=SOURCE$+"\"
  391.             end if
  392.             if mid$(DEST$,len(DEST$),1) <> "\" then 
  393.                 DEST$=DEST$+"\"
  394.             end if
  395.             CreateIniKeyValue (DEST$ + "TBM.INI"), "DRIVES", "CDPATH", SOURCE$, cmoOverwrite
  396.         END IF
  397.  
  398.     rem Indicate install completed OK
  399.     rem -----------------------------
  400.         Install = INSTALLOK
  401.  
  402. END FUNCTION
  403.  
  404. rem MakePath: Builds path from directory and file
  405. rem ---------------------------------------------
  406. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  407.  
  408.     IF szDir$ = "" THEN
  409.        MakePath = szFile$
  410.  
  411.     ELSEIF szFile$ = "" THEN
  412.        MakePath = szDir$
  413.  
  414.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  415.        MakePath = szDir$ + szFile$
  416.  
  417.     ELSE
  418.        MakePath = szDir$ + "\" + szFile$
  419.  
  420.     END IF
  421.  
  422. END FUNCTION
  423.  
  424.